$(function() {
	"use strict";

	Dropzone.options.myAwesomeDropzone = false;
	Dropzone.autoDiscover = false;

	//阻止弹出框点中面板内隐藏
	jQuery(document).on("click", ".page-bar-drop-menu", function(k) {
	        k.stopPropagation();
	});
	
	//文件上传菜单事件绑定
	$('.caution-upload').click(function(e) {
		var href = $(this).data("href");
		swal({
			title: "数据文件上传",
			text: "<div class='dropzone remind-upload-box'></div>",
			html: true,
			confirmButtonColor: '#007470',
			confirmButtonText: "关闭窗口"
		});
		$('.remind-upload-box').dropzone({
			url: href,
			acceptedFiles: ".xls,.xlsx",
			maxFilesize: 20, // MB
			uploadMultiple: false,
			dictDefaultMessage: "点这里上传新文件",
			error: function(file, error) {
				console.log(error);
			},
			success: function(file, response) {
				if (response && response.code === 'ok') {
					toastr.success("文件"+file.name+"上传完成！","成功提示",{
						timeOut: 3000,
						"positionClass": "toast-top-center",
				        "showMethod": "fadeIn",
				        "hideMethod": "fadeOut"
				    });
					swal.close();
				} else {
					toastr.error(response ? response.desc : '上传失败',"错误提示",{
						timeOut: 3000,
						"positionClass": "toast-top-center",
				        "showMethod": "fadeIn",
				        "hideMethod": "fadeOut"
				    });
				}
			}
		})
	})
});